import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';
export namespace PerFamilyEmigrationApi {
  /** 移居国外信息信息 */
  export interface FamilyEmigration {
    id: number; // 主键ID
    employeeId?: number; // 人员ID，对应 per_employee.id
    relation: string; // 与本人关系（称谓）
    systemPersonId: number; // 系统人员ID，对应 system_person.id
    familyName: string; // 移居人姓名
    cardType: string; // 证件类型
    familyIdcard: string; // 移居人证件号码
    country: string; // 移居国家地区
    currentResidence: string; // 现居住地
    emigrationType: string; // 移居类别
    emigrationTime: string | Dayjs; // 移居时间
    remark: string; // 备注
    status: number; // 状态（1：有效，0：无效）
  }
}

/** 查询移居国外信息分页 */
export function getFamilyEmigrationPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<
    PageResult<PerFamilyEmigrationApi.FamilyEmigration>
  >('/per/family-emigration/page', data, { desensitize, encrypt });
}

/** 查询移居国外信息详情 */
export function getFamilyEmigration(id: number) {
  return requestClient.get<PerFamilyEmigrationApi.FamilyEmigration>(
    `/per/family-emigration/get?id=${id}`,
  );
}

/** 新增移居国外信息 */
export function createFamilyEmigration(
  data: PerFamilyEmigrationApi.FamilyEmigration,
) {
  return requestClient.post('/per/family-emigration/create', data);
}

/** 修改移居国外信息 */
export function updateFamilyEmigration(
  data: PerFamilyEmigrationApi.FamilyEmigration,
) {
  return requestClient.put('/per/family-emigration/update', data);
}

/** 删除移居国外信息 */
export function deleteFamilyEmigration(id: number) {
  return requestClient.delete(`/per/family-emigration/delete?id=${id}`);
}

/** 批量删除移居国外信息 */
export function deleteFamilyEmigrationList(ids: number[]) {
  return requestClient.delete(
    `/per/family-emigration/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出移居国外信息 */
export function exportFamilyEmigration(params: any) {
  return requestClient.download('/per/family-emigration/export-excel', {
    params,
  });
}
